/**
*      author: Y_Yao
*      created: 2024-10-29 18:27:04
**/

#include<bits/stdc++.h>

using namespace std;
#define int LL
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 3e5 + 7;
int a[N],sz[N],zero[N];
int n;
int maxn = n;
//vector<vector<int,int>> m(N);


void dfs(unordered_map<int,int>& vis,map<int,vector<int>>& m)
{
    queue<int> q;
    q.push(n);

    while(!q.empty())
    {
        int t = q.front();
        q.pop();

        for(int i = 0;i < m[t].size();i++)
        {
            if(vis.find(m[t][i]) != vis.end())continue;
            vis[m[t][i]]++;
            maxn = max(maxn,m[t][i]);
            q.push(m[t][i]);
        }
    }
}

void solve()
{
    cin >> n;
    maxn = n;

    map<int,vector<int>> m;
    unordered_map<int,int> vis;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        sz[i] = a[i] + i - 1;
        zero[i] = sz[i] + i - 1;
        m[sz[i]].push_back(zero[i]);
    }
    dfs(vis,m);

    cout << maxn << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}